package per.liuyayiweb.util;
import java.io.*;
import java.net.Socket;
public class Resource
{
    public static void closeOutputStream(OutputStream os) {
        try {
            if (os != null) {
                os.flush();
                os.close();
            }
        } catch (IOException ignored) {
            System.err.println("this  will  never  happen");
        }
    }
    public static void closeInputStream(InputStream is) {
        try {
            if (is != null) {
                is.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void closeWriter(Writer writer) {
        try {
            if (writer != null) {
                writer.flush();
                writer.close();
            }
        } catch (IOException e) {
            System.err.println("this will never happen");
        }
    }
    public static void closeReader(Reader reader) {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException e) {
            System.err.println("this will never happen");

        }
    }
    public static void closeSocket(Socket socket) {
        try {
            if (socket != null&& !socket.isClosed()) {
                socket.close();
            }
        } catch (IOException e) {
            System.err.println("this will never happen");

        }
    }
}
